package com.example.service;

import com.example.entity.VideoCategory;
import com.example.entity.VideoComments;
import com.example.mapper.VideoCommentsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*视频评论业务处理
 */
@Service
public class VideoCommentsService {

    @Resource
    private VideoCommentsMapper videoCommentsMapper;

    public void add(VideoComments videoComments) {
        videoCommentsMapper.insert(videoComments);
    }

    public void deleteById(Integer id) {
        videoCommentsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(VideoComments videoComments) {
        videoCommentsMapper.updateById(videoComments);
    }

    public VideoComments selectById(Integer id) {
        return videoCommentsMapper.selectById(id);
    }

    public List<VideoComments> selectAll(VideoComments videoComments) {
        return videoCommentsMapper.selectAll(videoComments);
    }

    public PageInfo<VideoComments> selectPage(VideoComments videoComments, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<VideoComments> videoCommentsList = videoCommentsMapper.selectAll(videoComments);
        return PageInfo.of(videoCommentsList);
    }
}
